package com.manlitech.cloudboot.shardingjdbc.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.manlitech.cloudboot.basebootconfig.exception.MyException;
import com.manlitech.cloudboot.common.enums.ResultEnums;
import com.manlitech.cloudboot.shardingjdbc.mapper.UserInfoMapper;
import com.manlitech.cloudboot.shardingjdbc.pojo.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author shensg
 * @date 2021/7/21 13:36
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class UserInfoOtherServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> {
    @Autowired
    UserInfoMapper userInfoMapper;
    public void saveOther(UserInfo userInfo) {

        userInfoMapper.insert(userInfo);

        userInfo.setName("ssg");
        userInfoMapper.insert(userInfo);
        if(1==1){
            throw new MyException(ResultEnums.API_FLOW_EXCEPTION.getCode(),ResultEnums.API_FLOW_EXCEPTION.getMsg());
        }
    }
}
